package com.example.myservlet;

import com.example.anno.RequestMapping;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@RequestMapping("/form")
public class FormParamServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        req.setCharacterEncoding("UTF-8");
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        resp.setContentType("text/plain;charset=UTF-8");
        resp.getWriter().printf("username=%s, password=%s%n", username, password);
    }
}